package org.example.java.base;

import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;

/**
 * Created with IntelliJ IDEA.
 * User: ZhangJuntao
 * Date: 13-3-6
 * Time: 下午10:41
 */
public class SystemTest {
  public static void main(String[] args) throws InterruptedException {
//    testTime();
    testArraycopy();
  }

  private static void testArraycopy() {
    int[] a = {4, 3, 6, 73, 2};
    int[] b = new int[5];
    System.arraycopy(a, 3, b, 2, 2);
    for (int n : b) {
      System.out.print(n + " ");
    }
    System.out.println();
  }

  private static void testTime() throws InterruptedException {
    long start1 = System.nanoTime();
    long start2 = System.currentTimeMillis();    //毫秒    1秒=1000毫秒
    TimeUnit.SECONDS.sleep(2);                   //毫微秒  1秒=1000000000毫微秒  10亿
    long estimatedTime1 = System.nanoTime() - start1;
    long estimatedTime2 = System.currentTimeMillis() - start2;
    System.out.println(estimatedTime1);
    System.out.println(estimatedTime2);
    System.out.println(NANOSECONDS.convert(1, MILLISECONDS));//毫秒
  }
}
